package org.f0rb.demo.web;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ModelDriven;
import org.f0rb.core.web.WebModel;
import org.f0rb.core.web.WebService;

/**
 * Created by IntelliJ IDEA.
 * Author: yuanzhen
 * Date: 2010-8-30
 * Time: 15:02:05
 *
 * @param <T> {@link org.f0rb.core.web.WebModel}的子类
 */
public abstract class Struts2Action<T extends WebModel<?>> implements ModelDriven<T>, Action {
    private T model;

    public Struts2Action(T t) {
        model = t;
    }

    /**
     * Method getModel returns the model of this Struts2Action object.
     *
     * @return the model (type T) of this Struts2Action object.
     */
    @Override
    public final T getModel() {
        return model;
    }

    /**
     * Method execute ...
     *
     * @return String
     */
    @Override
    public String execute() {
        return getService().execute(model);
    }

    protected abstract WebService<T> getService();
}
